<template>
  <!-- <router-view name="LoginRouterView"/>
  <Index v-if="notLogin"/> -->
  <!-- 动态组件 -->
  <component :is="currentView"></component>
  
</template>

<script setup>
import { ref,shallowRef,watch} from 'vue';
import Index from '@/views/Index.vue';
import Login from '@/views/Login.vue';
import { useRoute } from 'vue-router';

const route = useRoute(); 
const currentView = shallowRef(route.name === 'LoginView' ? Login : Index);

// 设置监控，解决登录后跳转不到首页问题
watch(route, (newVal) => {
  currentView.value = newVal.name === 'LoginView' ? Login : Index;
}, { immediate: true })

</script>

<style>
* {
  margin: 0;
  padding: 0;
}
body {
  overflow: hidden;
}
</style>

